package com.zhouheng.kafkacommon.util;

import com.zhouheng.kafkacommon.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * KafkaMQ工具类
 *
 * @author 周恒
 * @date 20190304 16:12:32
 * @since v1.0
 */
@Component
public class KafkaUtil {

    private KafkaUtil(){ }

    @Autowired
    private KafkaTemplate<String, User> kafkaUserTemplate;

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void send(String topic, User user){
        kafkaUserTemplate.send(topic, user);
    }

    public void send(String topic, String message){
        kafkaTemplate.send(topic, message);
    }

}
